package com.arrayofsky.gateway;

import com.arrayofsky.gateway.server.SessionServer;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @Author: gaoyifeng
 * @Description:
 * @Date Created in 2024-06-18-14:46
 * @Modified By:
 */
@Slf4j
public class GatewayApplication {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        SessionServer server = new SessionServer();
        Future<Channel> future = Executors.newFixedThreadPool(2).submit(server);
        Channel channel = future.get();
        if (null == channel) {
            throw new RuntimeException("netty server start error channel is null");
        }

        while (!channel.isActive()) {
            log.info("NettyServer启动服务 ...");
            Thread.sleep(500);
        }
        log.info("NettyServer启动服务完成 {}", channel.localAddress());
        Thread.sleep(Long.MAX_VALUE);
    }

}
